# -*- coding: utf-8 -*-
import xbmc,xbmcgui,xbmcplugin,urllib2,urllib,re,sys,os
import StringIO,gzip

#sys.path.append('C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc')
#import pydevd
#pydevd.settrace('localhost', stdoutToServer=True, stderrToServer=True)

#SohuVedio- by robinttt 2010.

restmp=open(os.getcwd()+"\\resource.xml")
restxt=re.sub("\s","",restmp.read())

def GetGzippedURL(req):
        response = urllib2.urlopen(req)
        data = response.read()
        response.close()
        data = StringIO.StringIO(data)
        gzipper = gzip.GzipFile(fileobj=data)
        return gzipper.read()

def Roots():
        match=re.compile("<videotype='(.+?)'>").findall(restxt)
        for i in range(0,len(match)):
		li=xbmcgui.ListItem(match[i])
		u=sys.argv[0]+"?mode=1&name="+urllib.quote_plus(match[i])
		xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

def Types(name):
        match0=re.compile("<videotype='"+name+"'>(.+?)</video>").findall(restxt)
        match=re.compile("<typename='(.+?)'>").findall(match0[0])
        for i in range(0,len(match)):
		li=xbmcgui.ListItem(match[i])
		u=sys.argv[0]+"?mode=2&name="+urllib.quote_plus(match[i])
		xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

def Lists(name):
        match0=re.compile("<typename='"+name+"'>(.+?)</type>").findall(restxt)
        match=re.compile("<list><url><\!\[CDATA\[(.+?)\]\]></url><name>(.+?)</name></list>").findall(match0[0])
        for i in range(0,len(match)):
                if name=="高清电视剧>类型" or name=="高清电影>类型" or name=="高清纪录片>专区" or name=="高清电视剧>地区" or name=="高清电影>地区" or name=="高清电影>年份":
			li=xbmcgui.ListItem(name+">"+match[i][1])
                        u=sys.argv[0]+"?mode=5&name="+urllib.quote_plus(name+">"+match[i][1])+"&url="+urllib.quote_plus(match[i][0])
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                elif name=="高清电视剧>评分" or name=="高清电影>评分" or name=="高清电影>个性" or name=="高清纪录片>类型" or name=="高清纪录片>个性":
			li=xbmcgui.ListItem(name+">"+match[i][1])
                        u=sys.argv[0]+"?mode=7&name="+urllib.quote_plus(name+">"+match[i][1])+"&url="+urllib.quote_plus(match[i][0])+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                elif name=="高清电视剧>榜单" or name=="高清电影>榜单" or name=="高清纪录片>榜单":
			li=xbmcgui.ListItem(name+">"+match[i][1])
                        u=sys.argv[0]+"?mode=8&name="+urllib.quote_plus(name+">"+match[i][1])+"&url="+urllib.quote_plus(match[i][0])
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                elif name=="视频新闻>类型":
			li=xbmcgui.ListItem(name+">"+match[i][1])
                        u=sys.argv[0]+"?mode=9&name="+urllib.quote_plus(name+">"+match[i][1])+"&url="+urllib.quote_plus(match[i][0])+"&pagen="+urllib.quote_plus("")
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                elif name=="视频新闻>排行":
			li=xbmcgui.ListItem(name+">"+match[i][1])
                        u=sys.argv[0]+"?mode=10&name="+urllib.quote_plus(name+">"+match[i][1])+"&url="+urllib.quote_plus(match[i][0])
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                elif name=="高清电影>明星":
			li=xbmcgui.ListItem(name+">"+match[i][1])
                        u=sys.argv[0]+"?mode=11&name="+urllib.quote_plus(name+">"+match[i][1])+"&url="+urllib.quote_plus(match[i][0])
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                elif name=="电视节目>类型":
			li=xbmcgui.ListItem(name+">"+match[i][1])
                        u=sys.argv[0]+"?mode=12&name="+urllib.quote_plus(name+">"+match[i][1])+"&url="+urllib.quote_plus(match[i][0])+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                elif name=="电视节目>排行":
                        req = urllib2.Request("http://tv.sohu.com/frag/tv_inc/nominate2json50.inc")
                        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
                        response = urllib2.urlopen(req)
                        link=response.read()
                        response.close()
                        link=re.sub("\s","",link)
	                li=xbmcgui.ListItem("当前位置："+name)
	                u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
	                xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
                        match=re.compile('"name":"(.+?)","name_url":"(.+?)"').findall(link)
                        for i in range(0,len(match)):
	                	li=xbmcgui.ListItem(str(i+1)+'.'+match[i][0].decode('gb18030').encode('utf8'))
                                u=sys.argv[0]+"?mode=14&name="+urllib.quote_plus(name+">"+match[i][0].decode('gb18030').encode('utf8'))+"&url="+urllib.quote_plus(match[i][1].decode('gb18030').encode('utf8'))
	                	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                elif name=="电视节目>电视台":
                        req = urllib2.Request("http://tv.sohu.com/zhibo/")
                        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
                        response = urllib2.urlopen(req)
                        link=response.read()
                        response.close()
                        link=re.sub("\s","",link)
	                li=xbmcgui.ListItem("当前位置："+name)
	                u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
	                xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
                        match=re.compile('case(.+?)playurl="(.+?)";//(.+?)break;').findall(link)
                        for i in range(0,len(match)):
	                	li=xbmcgui.ListItem(str(i+1)+'.'+match[i][2].decode('gb18030').encode('utf8'))
                                u=sys.argv[0]+"?mode=12&name="+urllib.quote_plus(name+">"+match[i][2].decode('gb18030').encode('utf8'))+"&url="+urllib.quote_plus("http://data.tv.sohu.com/lanmu/searchTvColumn.action?searchValue="+urllib.quote(match[i][2])+"&enflag=1&searchType=tvName&page=")+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
	                	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)





def ListA(name,url):
	li=xbmcgui.ListItem(name+">最多播放")
	u=sys.argv[0]+"?mode=4&name="+urllib.quote_plus(name+">最多播放")+"&url="+urllib.quote_plus(url+"&sort=4&page=")+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
	li=xbmcgui.ListItem(name+">最新发布")
	u=sys.argv[0]+"?mode=4&name="+urllib.quote_plus(name+">最新发布")+"&url="+urllib.quote_plus(url+"&sort=1&page=")+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
	li=xbmcgui.ListItem(name+">最热播放")
	u=sys.argv[0]+"?mode=4&name="+urllib.quote_plus(name+">最热播放")+"&url="+urllib.quote_plus(url+"&sort=3&page=")+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
	li=xbmcgui.ListItem(name+">相关程度")
	u=sys.argv[0]+"?mode=4&name="+urllib.quote_plus(name+">相关程度")+"&url="+urllib.quote_plus(url+"&sort=2&page=")+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

def ListA1(name,url,pagen,pagec):
        url1=""
        for item in url.decode("utf8"):
                if len("%X"%ord(item))==4:url1=url1+"%u"+"%X"%ord(item)
                else:url1=url1+item
        url1=url1+pagen
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        link=re.sub("\s","",link)

        match=re.compile('"resultNum"\:(.+?)\,"').findall(link)
        if len(match)!=0:
                if pagen=="1":
                        if int(match[0])%50==0:pagec=str(int(match[0])/50)
                        else:pagec=str(int(match[0])/50+1)
		li=xbmcgui.ListItem("当前位置："+name+" 第"+pagen+"/"+pagec+"页")
		u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
		xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
                match=re.compile('"director":(.+?)","from":(.+?)","intro":(.+?)","score":(.+?)","(.+?)"playUrl":(.+?)","thumbUrl":(.+?)","title":(.+?)"').findall(link)
                for i in range(0,len(match)):
			li=xbmcgui.ListItem(str(i+1)+'.'+match[i][7].replace('"','').decode('gb18030').encode('utf8')+"【"+match[i][3].replace('"','')[0:3]+'分】',match[i][6].replace('"','').decode('gb18030').encode('utf8'),match[i][6].replace('"','').decode('gb18030').encode('utf8'))
			u=sys.argv[0]+"?mode=19&name="+urllib.quote_plus(match[i][7].replace('"','').decode('gb18030').encode('utf8'))+"&url="+urllib.quote_plus(match[i][5].replace('"','').decode('gb18030').encode('utf8'))+"&director="+urllib.quote_plus(match[i][0].replace('"','').decode('gb18030').encode('utf8'))+"&studio="+urllib.quote_plus(match[i][1].replace('"','').decode('gb18030').encode('utf8'))+"&plot="+urllib.quote_plus(match[i][2].replace('"','').decode('gb18030').encode('utf8'))
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                if int(pagen)>1:
			li=xbmcgui.ListItem("..第一页")
			u=sys.argv[0]+"?mode=4&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
			li=xbmcgui.ListItem("..上一页")
			u=sys.argv[0]+"?mode=4&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)-1))+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                if int(pagen)<int(pagec):
			li=xbmcgui.ListItem("..下一页")
			u=sys.argv[0]+"?mode=4&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)+1))+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
			li=xbmcgui.ListItem("..最后页")
			u=sys.argv[0]+"?mode=4&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(pagec)+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)


def ListB(name,url):
	li=xbmcgui.ListItem(name+">最多播放")
	u=sys.argv[0]+"?mode=6&name="+urllib.quote_plus(name+">最多播放")+"&url="+urllib.quote_plus(url+"&o=1&p=")+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True, 20)
	li=xbmcgui.ListItem(name+">最新发布")
	u=sys.argv[0]+"?mode=6&name="+urllib.quote_plus(name+">最新发布")+"&url="+urllib.quote_plus(url+"&o=3&p=")+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
	li=xbmcgui.ListItem(name+">最高评分")
	u=sys.argv[0]+"?mode=6&name="+urllib.quote_plus(name+">最高评分")+"&url="+urllib.quote_plus(url+"&o=4&p=")+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
	li=xbmcgui.ListItem(name+">相关程度")
	u=sys.argv[0]+"?mode=6&name="+urllib.quote_plus(name+">相关程度")+"&url="+urllib.quote_plus(url+"&p=")+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

def ListB1(name,url,pagen,pagec):
        url1=""
        for item in url.decode("utf8"):
                if len("%X"%ord(item))==4:url1=url1+"%u"+"%X"%ord(item)
                else:url1=url1+item
        url1=url1+pagen
        
        #url1="so.tv.sohu.com/mts?chl=&c=2&area=%u5185%u5730&whole=1&o=1&p=1"
        req = urllib2.Request(url1.encode("gb18030"))
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        response = urllib2.urlopen(req)
        link=response.read(30000)
        response.close()
        link=re.sub("\s","",link)
        match=re.compile('<liclass="page">\d?/(.+?)</li>').findall(link)
        #li=xbmcgui.ListItem(match[0])
        #u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
        #xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
        if len(match)!=0:
            if pagen=="1":pagec=match[0]
            li=xbmcgui.ListItem("当前位置："+name+" 第"+pagen+"/"+pagec+"页")
            u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
            xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
            #match=re.compile('<divclass="ptListclear"><divclass="l"><ahref="(.+?)"(.+?)<imgsrc="(.+?)"alt="(.+?)"(.+?)<fontclass="timetip">(.+?)</font>(.+?)<p>(.+?)</p>').findall(link)
            match=re.compile('<h4><spanclass="t">(.+?)</span><spanclass="d"><font>(.+?)</font>.+?<p>(.+?)</p></div><aclass="img"href="/to\?u=(.+?)&k=.+?<imgsrc="(.+?)"alt="').findall(link)
            for i in range(0,len(match)):
                li=xbmcgui.ListItem(str(i+1)+'.'
                    +match[i][0].decode('gb18030').encode('utf8')+"【"+match[i][1].decode('gb18030').encode('utf8')+"】",match[i][4].decode('gb18030').encode('utf8'),match[i][4].decode('gb18030').encode('utf8'))
                u=sys.argv[0]+"?mode=19&name="+urllib.quote_plus(match[i][0].decode('gb18030').encode('utf8'))+"&url="+urllib.quote_plus(match[i][3].decode('gb18030').encode('utf8'))+"&director="+urllib.quote_plus("")+"&studio="+urllib.quote_plus("")+"&plot="+urllib.quote_plus(match[i][2].decode('gb18030').encode('utf8'))
                xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
            if int(pagen)>1:
			        li=xbmcgui.ListItem("..第一页")
			        u=sys.argv[0]+"?mode=6&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus(pagec)
			        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
			        li=xbmcgui.ListItem("..上一页")
			        u=sys.argv[0]+"?mode=6&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)-1))+"&pagec="+urllib.quote_plus(pagec)
			        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
            if int(pagen)<int(pagec):
			        li=xbmcgui.ListItem("..下一页")
			        u=sys.argv[0]+"?mode=6&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)+1))+"&pagec="+urllib.quote_plus(pagec)
			        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
			        li=xbmcgui.ListItem("..最后页")
			        u=sys.argv[0]+"?mode=6&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(pagec)+"&pagec="+urllib.quote_plus(pagec)
			        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

def ListC(name,url,pagen,pagec):
        url1=""
        for item in url.decode("utf8"):
                if len("%X"%ord(item))==4:url1=url1+"%25u"+"%X"%ord(item)
                else:url1=url1+item
        href=re.compile("http://search.vrs.sohu.com/video(.+?)_s_n(.+?)_p100(.+?)json").findall(url1)
        url2="http://search.vrs.sohu.com/video"+href[0][0]+"_s_n"+pagen+"_p100"+href[0][2]+"json"

        req = urllib2.Request(url2)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        link=re.sub("\s","",link)

        match=re.compile('"totalCount":(.+?),').findall(link)
        if len(match)!=0:
                if pagen=="1":
                        if int(match[0])%100==0:pagec=str(int(match[0])/100)
                        else:pagec=str(int(match[0])/100+1)
		li=xbmcgui.ListItem("当前位置："+name+" 第"+pagen+"/"+pagec+"页")
		u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
		xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)

                #match=re.compile('"videoDirector":(.+?)","videoTip":(.+?)","(.+?)"videoUrl":"(.+?)","(.+?)"videoBigPic":"(.+?)","videoName":"(.+?)","(.+?)"videoScore":(.+?),(.+?)"videoDesc":"(.+?)"').findall(link)
                match=re.compile('"videoDirector":(.+?)","videoTip":(.+?)",.+?,"videoName":"(.+?)",.+?,"videoDesc":"(.+?)",.+?,"videoUrl":"(.+?)",.+?,"videoBigPic":"(.+?)",.+?"videoScore":(.+?),"videoKeyword"').findall(link)
                for i in range(0,len(match)):
			li=xbmcgui.ListItem(str(i+1)+'.'+match[i][2].decode('gb18030').encode('utf8')+"【"+match[i][1].replace('"','').decode('gb18030').encode('utf8')+","+match[i][6][0:3]+"分】",match[i][5].decode('gb18030').encode('utf8'),match[i][5].decode('gb18030').encode('utf8'))
                        u=sys.argv[0]+"?mode=19&name="+urllib.quote_plus(match[i][2].decode('gb18030').encode('utf8'))+"&url="+urllib.quote_plus(match[i][4].decode('gb18030').encode('utf8'))+"&director="+urllib.quote_plus(match[i][0].replace('"','').decode('gb18030').encode('utf8'))+"&studio="+urllib.quote_plus("")+"&plot="+urllib.quote_plus(match[i][3].decode('gb18030').encode('utf8'))
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

                if int(pagen)>1:
			li=xbmcgui.ListItem("..第一页")
			u=sys.argv[0]+"?mode=7&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
			li=xbmcgui.ListItem("..上一页")
			u=sys.argv[0]+"?mode=7&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)-1))+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                if int(pagen)<int(pagec):
			li=xbmcgui.ListItem("..下一页")
			u=sys.argv[0]+"?mode=7&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)+1))+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
			li=xbmcgui.ListItem("..最后页")
			u=sys.argv[0]+"?mode=7&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(pagec)+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

def ListD(name,url):
        #榜单(js文件)获取有时不正常，多刷几次就能看到，暂时没找到原因
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        link=GetGzippedURL(req)
        link=re.sub("\s","",link)
	li=xbmcgui.ListItem("当前位置："+name)
	u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
        #match=re.compile('"tv_source":(.+?)","DIRECTOR":(.+?)","tv_count":"(.+?)","tv_comment":"(.+?)"(.+?)"tv_url":"(.+?)","(.+?)"tv_name":"(.+?)","(.+?)"tv_big_pic":"(.+?)"').findall(link)
        match=re.compile('"tv_all_count":"(.+?)",.+?,"DIRECTOR":"(.+?)","tv_source":"(.+?)",.+?,"tv_comment":"(.+?)",.+?,"tv_big_pic":"(.+?)",.+?,"tv_url":"(.+?)","tv_name":"(.+?)",').findall(link)

        for i in range(0,len(match)):
		li=xbmcgui.ListItem(str(i+1)+'.'+match[i][6].decode('gb18030').encode('utf8')+"【"+match[i][0]+"次】",match[i][4].decode('gb18030').encode('utf8'),match[i][4].decode('gb18030').encode('utf8'))
                u=sys.argv[0]+"?mode=801&name="+urllib.quote_plus(match[i][6].decode('gb18030').encode('utf8'))+"&url="+urllib.quote_plus(match[i][5].decode('gb18030').encode('utf8'))+"&director="+urllib.quote_plus(match[i][1].replace('"','').decode('gb18030').encode('utf8'))+"&studio="+urllib.quote_plus(match[i][0].replace('"','').decode('gb18030').encode('utf8'))+"&plot="+urllib.quote_plus(match[i][3].decode('gb18030').encode('utf8'))
		xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

def ListD1(name,url):
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        link=GetGzippedURL(req)
        link = re.sub("\s", "", link)
        url=re.compile('tdalign=middle><ahref="(.+?)"').search(link).group(1)
        MovieId(name,url,"","","")

def ListE(name,url,pagen):
        #视频新闻>类型模块网站的数据在最后几页经常出现异常，加入try捕获异常及时退出
        try:
                if pagen=="":
                        url1=url+"index.shtml"
                else:
                        url1=url+"index_"+str(int(pagen))+".shtml"
                req = urllib2.Request(url1)
                req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
                response = urllib2.urlopen(req)
                link=response.read()
                response.close()
                link=re.sub("\s","",link)
                match=re.compile('varmaxPage=(.+?);').findall(link)
                if pagen=="":pagen=match[0]
                if int(match[0])>100:pagec="100"
                else:pagec=match[0]
                page=match[0]
                li=xbmcgui.ListItem("当前位置："+name+" 第"+str(int(page)-int(pagen)+1)+"/"+pagec+"页")
        	u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
        	xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
                #match=re.compile('<divclass="vImg"><ahref="(.+?)"target="_blank"><imgsrc="(.+?)"alt="(.+?)"(.+?)<pclass="vUpdate">(.+?)</p>').findall(link)
                match=re.compile('<divclass="vImg"><ahref="(.+?)"target="_blank"><imgsrc="(.+?)"alt="(.+?)"(.+?)<pclass="vUpdate">(.+?)</p>').findall(link)
                for i in range(0,len(match)):
			li=xbmcgui.ListItem(str(i+1)+'.'+match[i][2].decode('gb18030').encode('utf8')+"【"+match[i][4].decode('gb18030').encode('utf8')+"】",match[i][1].decode('gb18030').encode('utf8'),match[i][1].decode('gb18030').encode('utf8'))
                        u=sys.argv[0]+"?mode=21&name="+urllib.quote_plus(match[i][2].decode('gb18030').encode('utf8'))+"&url="+urllib.quote_plus(match[i][0].decode('gb18030').encode('utf8'))
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
                if int(pagen)<int(page):
	        	li=xbmcgui.ListItem("..第一页")
	        	u=sys.argv[0]+"?mode=21&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus("")
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
		        li=xbmcgui.ListItem("..上一页")
                        if int(pagen)<int(page)-1:
		                u=sys.argv[0]+"?mode=9&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)+1))
                        else:
		                u=sys.argv[0]+"?mode=9&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus("")
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
	        if int(pagen)>int(page)-int(pagec)+1:
	        	li=xbmcgui.ListItem("..下一页")
		        u=sys.argv[0]+"?mode=9&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)-1))
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
		        li=xbmcgui.ListItem("..最后页")
		        u=sys.argv[0]+"?mode=9&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(page)-int(pagec)+1))
		        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

        except:pass

def ListF(name,url):
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        link=re.sub("\s","",link)
	if name=="视频新闻>排行>24小时排行":match0=re.compile('<divclass="column462left">(.+?)<divclass="bot462A"></div></div></div>').findall(link)
        else:match0=re.compile('<divclass="column462right">(.+?)<divclass="bot462A"></div></div></div>').findall(link)
        li=xbmcgui.ListItem("当前位置："+name)
        u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
        xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
        match=re.compile('<ahref="(.+?)"target="_blank">(.+?)</a></li>').findall(match0[0])
        for i in range(0,len(match)):
		li=xbmcgui.ListItem(str(i+1)+'.'+match[i][1].decode('gb18030').encode('utf8'))
                u=sys.argv[0]+"?mode=21&name="+urllib.quote_plus(match[i][1].decode('gb18030').encode('utf8'))+"&url="+urllib.quote_plus(match[i][0].decode('gb18030').encode('utf8'))
		xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)

def ListG(name,url):
        #搜狐没有明星列表，借用迅雷看看的
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        link=re.sub("\s","",link)
        match0=re.compile('<divclass="starTextList">(.+?)</div>').findall(link)
        match=re.compile('<ahref="(.+?)"title="(.+?)"').findall(match0[0])
        for i in range(0,len(match)):
		li=xbmcgui.ListItem(name+">"+match[i][1])
		u=sys.argv[0]+"?mode=5&name="+urllib.quote_plus(name+">"+match[i][1])+"&url="+urllib.quote_plus("http://so.tv.sohu.com/mts?chl=&wd="+match[i][1]+"&whole=1&c=1")
		xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

def ListH(name,url,pagen,pagec):
        req = urllib2.Request(url.decode("utf8").encode("gb18030")+pagen)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        link=re.sub("\s","",link)
        match=re.compile(u"共有\(".encode("gb18030")+"(.+?)"+u"\)".encode("gb18030")).findall(link)
        if len(match)!=0:
                if pagen=="1":
                        if int(match[0])%20==0:pagec=str(int(match[0])/20)
                        else:pagec=str(int(match[0])/20+1)
		li=xbmcgui.ListItem("当前位置："+name+" 第"+pagen+"/"+pagec+"页")
		u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
		xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
                match=re.compile('<divclass="picTextGroup">(.+?)alt="(.+?)"><imgsrc="(.+?)"(.+?)<p>(.+?)>(.+?)</a>').findall(link)
                for i in range(0,len(match)):
			li=xbmcgui.ListItem(str(i+1)+'.'+match[i][1].decode('gb18030').encode('utf8')+"【"+match[i][5].decode('gb18030').encode('utf8')+"】","http://data.tv.sohu.com"+match[i][2].decode('gb18030').encode('utf8'),"http://data.tv.sohu.com"+match[i][2].decode('gb18030').encode('utf8'))
                        u=sys.argv[0]+"?mode=13&name="+urllib.quote_plus(name+">"+match[i][1].decode('gb18030').encode('utf8'))+"&url="+urllib.quote_plus(match[i][5].decode('gb18030').encode('utf8'))+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus("1")
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                if int(pagen)>1:
			li=xbmcgui.ListItem("..第一页")
			u=sys.argv[0]+"?mode=12&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
			li=xbmcgui.ListItem("..上一页")
			u=sys.argv[0]+"?mode=12&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)-1))+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
                if int(pagen)<int(pagec):
			li=xbmcgui.ListItem("..下一页")
			u=sys.argv[0]+"?mode=12&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)+1))+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
			li=xbmcgui.ListItem("..最后页")
			u=sys.argv[0]+"?mode=12&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(pagec)+"&pagec="+urllib.quote_plus(pagec)
			xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

def ListH1(name,url,pagen,pagec):
# do not use url (channel info like BTV) in search
        url=""
        names=name.split(">")
        name1=names[len(names)-1]
        req = urllib2.Request("http://v.sogou.com/v?query="+urllib.quote(url.decode("utf8").encode("gb18030"))+"+"+urllib.quote(name1.decode("utf8").encode("gb18030"))+"&insite=sohu.com&page="+pagen)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        link=re.sub("\s","",link)
        match=re.compile("<!--resultbarnum:(.+?)-->").findall(link)
        if len(match)!=0:
                if pagen=="1":
                        match[0]=re.sub(",","",match[0])
                        if int(match[0])%20==0:pagec=str(int(match[0])/20)
                        else:pagec=str(int(match[0])/20+1)
		li=xbmcgui.ListItem("当前位置："+name+" 第"+pagen+"/"+pagec+"页")
		u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
		xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
        li=xbmcgui.ListItem(url)
        u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
        #xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
        match=re.compile('<atarget="_blank"href="(.+?)"id=.+?<imgsrc="(.+?)".+?title="(.+?)".+?'+u'发布时间:'.encode('gb18030')+'(.+?)<br>').findall(link)
        for i in range(0,len(match)):
            li=xbmcgui.ListItem(str(i+1)+'.'+match[i][2].decode('gb18030').encode('utf8').replace("&quot;","")+"【"+match[i][3].decode('gb18030').encode('utf8')+"】",match[i][1].decode('gb18030').encode('utf8'),match[i][1].decode('gb18030').encode('utf8'))
            u=sys.argv[0]+"?mode=21&name="+urllib.quote_plus(match[i][2].decode('gb18030').encode('utf8').replace("&quot;",""))+"&url="+urllib.quote_plus(match[i][0].decode('gb18030').encode('utf8'))
            xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
        if int(pagen)>1:
            li=xbmcgui.ListItem("..第一页")
            u=sys.argv[0]+"?mode=13&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus("1")+"&pagec="+urllib.quote_plus(pagec)
            xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
            li=xbmcgui.ListItem("..上一页")
            u=sys.argv[0]+"?mode=13&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)-1))+"&pagec="+urllib.quote_plus(pagec)
            xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
        if int(pagen)<int(pagec):
            li=xbmcgui.ListItem("..下一页")
            u=sys.argv[0]+"?mode=13&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(str(int(pagen)+1))+"&pagec="+urllib.quote_plus(pagec)
            xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)
            li=xbmcgui.ListItem("..最后页")
            u=sys.argv[0]+"?mode=13&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(url)+"&pagen="+urllib.quote_plus(pagec)+"&pagec="+urllib.quote_plus(pagec)
            xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li,True)

def ListI(name,url):
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        link=re.sub("\s","",link)
        match=re.compile('ahref="/lanmu/searchTvColumn\.action\?searchValue=(.+?)&enflag=1&searchType=tvName"target="_self"').findall(link)
        if len(match)>0:
            ListH1(name,match[0][0].decode('gb18030').encode('utf8'),"1","1")

def MovieId(name,url,director,studio,plot):
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        link=GetGzippedURL(req)
        link=re.sub(' ','',link)
        match=re.compile('varvid="(.+?)";').findall(link)
        vid=match[0]
        match=re.compile('varpid="(.+?)";').findall(link)
        pid=match[0]
        url='http://hot.vrs.sohu.com/vrs_videolist.action?vid='+vid+'&pid='+pid
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        match=re.compile('"videoImage":"(.+?)"(.+?)"videoId":(.+?),"(.+?)"videoName":"(.+?)"').findall(link)
        if len(match)>0:
		li=xbmcgui.ListItem("当前视频："+name)
		u=sys.argv[0]+"?mode=40&name="+urllib.quote_plus(name)
		xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)
                for i in range(0,len(match)):
                        li=xbmcgui.ListItem(str(i+1)+'.'+match[i][4].decode('gb18030').encode('utf8'),match[i][0].decode('gb18030').encode('utf8'),match[i][0].decode('gb18030').encode('utf8'))
                        li.setInfo(type="Video",infoLabels={"Title":match[i][4].decode('gb18030').encode('utf8'),"Director":director,"Studio":studio,"Plot":plot})
                	u=sys.argv[0]+"?mode=20&name="+urllib.quote_plus(match[i][4].decode('gb18030').encode('utf8'))+"&url="+urllib.quote_plus(match[i][2].decode('gb18030').encode('utf8'))+"&thumb="+urllib.quote_plus(match[i][0].decode('gb18030').encode('utf8'))+"&director="+urllib.quote_plus(director)+"&studio="+urllib.quote_plus(studio)+"&plot="+urllib.quote_plus(plot)
	                xbmcplugin.addDirectoryItem(int(sys.argv[1]),u,li)

def MoviePlay(name,url,thumb,director,studio,plot):
        url='http://hot.vrs.sohu.com/vrs_flash.action?vid='+url
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        link=re.sub("\s","",link)
        match=re.compile('"clipsURL"\:\["(.+?)"\]').findall(link)
        paths=match[0].split('","')
        playlist=xbmc.PlayList(1)
        playlist.clear()
        for i in range(0,len(paths)):
	        listitem=xbmcgui.ListItem(name,thumb,thumb)
                listitem.setInfo(type="Video",infoLabels={"Title":name+" 第"+str(i+1)+"/"+str(len(paths))+" 节","Director":director,"Studio":studio,"Plot":plot})
                playlist.add(paths[i], listitem)
        xbmc.Player().play(playlist)

def VideoPlay(name,url):
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
        link=GetGzippedURL(req)
        link=re.sub("\s","",link)
        match=re.compile('varflvname="(.+?)"').findall(link)
        if match[0].find("http://data.vod.sohu.com/")!=-1:
                playlist=xbmc.PlayList(1)
                playlist.clear()
                listitem=xbmcgui.ListItem(name)
                listitem.setInfo(type="Video",infoLabels={"Title":name})
                playlist.add(match[0], listitem)
                xbmc.Player().play(playlist)
        else:
                match=re.compile('varvid="(.+?)";').findall(link)
                url='http://hot.vrs.sohu.com/vrs_flash.action?vid='+match[0]
                req = urllib2.Request(url)
                req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729)')
                response = urllib2.urlopen(req)
                link=response.read()
                response.close()
                link=re.sub("\s","",link)
                match=re.compile('"clipsURL"\:\["(.+?)"\]').findall(link)
                paths=match[0].split('","')
                playlist=xbmc.PlayList(1)
                playlist.clear()
                for i in range(0,len(paths)):
	                listitem=xbmcgui.ListItem(name)
                        listitem.setInfo(type="Video",infoLabels={"Title":name+" 第"+str(i+1)+"/"+str(len(paths))+" 节"})
                        playlist.add(paths[i], listitem)
                xbmc.Player().play(playlist)



def get_params():
        param=[]
        paramstring=sys.argv[2]
        if len(paramstring)>=2:
                params=sys.argv[2]
                cleanedparams=params.replace('?','')
                if (params[len(params)-1]=='/'):
                        params=params[0:len(params)-2]
                pairsofparams=cleanedparams.split('&')
                param={}
                for i in range(len(pairsofparams)):
                        splitparams={}
                        splitparams=pairsofparams[i].split('=')
                        if (len(splitparams))==2:
                                param[splitparams[0]]=splitparams[1]
                                
        return param

params=get_params()
mode=None
name=None
url=None
jsono=None
pagen=None
pagec=None
type=None
thumb=None
director=None
studio=None
plot=None

try:
        url=urllib.unquote_plus(params["url"])
except:
        pass
try:
        name=urllib.unquote_plus(params["name"])
except:
        pass
try:
        type=urllib.unquote_plus(params["type"])
except:
        pass
try:
        jsono=urllib.unquote_plus(params["jsono"])
except:
        pass
try:
        pagen=urllib.unquote_plus(params["pagen"])
except:
        pass
try:
        pagec=urllib.unquote_plus(params["pagec"])
except:
        pass
try:
        director=urllib.unquote_plus(params["director"])
except:
        pass
try:
        studio=urllib.unquote_plus(params["studio"])
except:
        pass
try:
        plot=urllib.unquote_plus(params["plot"])
except:
        pass
try:
        thumb=urllib.unquote_plus(params["thumb"])
except:
        pass
try:
        mode=int(params["mode"])
except:
        pass

try:
    if mode==None:
    	name=''
    	Roots()
    elif mode==1:
    	Types(name)
    elif mode==2:
    	Lists(name)
    elif mode==3:
    	ListA(name,url)
    elif mode==4:
    	ListA1(name,url,pagen,pagec)
    elif mode==5:
    	ListB(name,url)
    elif mode==6:
    	ListB1(name,url,pagen,pagec)
    elif mode==7:
    	ListC(name,url,pagen,pagec)
    elif mode==8:
    	ListD(name,url)
    elif mode==801:
    	ListD1(name,url)
    elif mode==9:
    	ListE(name,url,pagen)
    elif mode==10:
    	ListF(name,url)
    elif mode==11:
    	ListG(name,url)
    elif mode==12:
    	ListH(name,url,pagen,pagec)
    elif mode==13:
    	ListH1(name,url,pagen,pagec)
    elif mode==14:
    	ListI(name,url)
    elif mode==19:
    	MovieId(name,url,director,studio,plot)
    elif mode==20:
    	MoviePlay(name,url,thumb,director,studio,plot)
    elif mode==21:
    	VideoPlay(name,url)
except:
	pass


xbmcplugin.setPluginCategory(int(sys.argv[1]), name )
xbmcplugin.endOfDirectory(int(sys.argv[1]))

    
